import request,{createService} from '@utils/request'
import BASE_URL,{tokenKey} from '../javaBaseUrl'
const javaRequest = createService(BASE_URL,tokenKey)
//域页面接口
export const getDomainsList = (data) => {
    return request.get(`/api/domains/domainslist?page=${data.pageNo}&pagesize=${data.pageSize}`)
}
export const domainsAdd = (data) => {
    return request.post(`/api/domains/domainsadd`, data)
}
export const domainsEdit = (data) => {
    return request.post(`/api/domains/domainsedit`, data)
}
export const domainsSetStatus = (data) => {
    return request.post(`/api/domains/domainssetstatus`, data)
}
export const domainDel = (data) => {
    return request.get(`/api/domains/domainsdel?id=${data}`)
}

//角色页面接口
// export const getRolesList = (data) => {
//     return request.get(`/api/roles/roleslist?page=${data.pageNo}&pagesize=${data.pageSize}`)
// }
export const getRolesList = (data) => {
    return javaRequest.get(`/permission/roles?pageNo=${data.pageNo}&pageSize=${data.pageSize}`)
}
// export const rolesAdd = (data) => {
//     return request.post(`/api/roles/rolesadd`, data)
// }
export const rolesAdd = (data) => {
    return javaRequest.post(`/permission/roles`, data)
}
// export const rolesEdit = (data) => {
//     return request.post(`/api/roles/rolesedit`, data)
// }
export const rolesEdit = (data) => {
    return javaRequest.put(`/permission/roles`, data)
}
export const rolesSetStatus = (data) => {
    return request.post(`/api/roles/rolessetstatus`, data)
}
// export const rolesDel = (data) => {
//     return request.get(`/api/roles/rolesdel?roles_id=${data}`)
// }
export const rolesDel = (data) => {
    return javaRequest.delete(`/permission/roles`,{data:data})
}


//规则页面接口
export const getPolicyList = (data) => {
    return request.get(`/api/policy/policylist?page=${data.pageNo}&pagesize=${data.pageSize}`)
}

export const policyAdd = (data) => {
    return request.post(`/api/policy/policyadd`, data)
}
export const policyEdit = (data) => {
    return request.post(`/api/policy/policyedit`, data)
}
export const policySetStatus = (data) => {
    return request.post(`/api/policy/policysetstatus`, data)
}
export const policyDel = (data) => {
    return request.get(`/api/policy/policydel?policy_id=${data}`)
}

//域角色绑定关系页面接口
export const getDomainsRolesList = (data) => {
    return request.get(`/api/relation/domainsroleslist?page=${data.pageNo}&pagesize=${data.pageSize}`)
}
export const domainsRolesAdd = (data) => {
    return request.post(`/api/relation/domainsrolesadd`, data)
}
export const domainsRolesEdit = (data) => {
    return request.post(`/api/relation/domainsrolesedit`, data)
}
export const domainsRolesSetStatus = (data) => {
    return request.post(`/api/relation/domainsrolessetstatus`, data)
}
export const domainsRolesDel = (data) => {
    return request.get(`/api/relation/domainsrolesdel?id=${data}`)
}

export default {
    getDomainsList,
    domainsAdd,
    domainsEdit,
    domainsSetStatus,
    domainDel,
    getRolesList,
    rolesAdd,
    rolesEdit,
    rolesSetStatus,
    rolesDel,
    getPolicyList,
    policyAdd,
    policyEdit,
    policySetStatus,
    policyDel,
    getDomainsRolesList,
    domainsRolesAdd,
    domainsRolesEdit,
    domainsRolesSetStatus,
    domainsRolesDel,
}